package tag_javastudy;

import java.io.IOException;
import java.io.StringWriter;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.JspFragment;
import javax.servlet.jsp.tagext.SimpleTagSupport;

public class Add extends SimpleTagSupport {

	//jsp2.x 继承SimpleTagSupport 开发标签
	
	String numb1;
	String numb2;	
	
	public void setNumb1(String numb1) {
		this.numb1 = numb1;
	}


	public void setNumb2(String numb2) {
		this.numb2 = numb2;
	}


	@Override
	public void doTag() throws JspException, IOException {
		// TODO Auto-generated method stub
	
		JspWriter out=this.getJspContext().getOut();
		int num=(Integer.parseInt(numb1)+Integer.parseInt(numb2));
		JspFragment jf=this.getJspBody();
		StringWriter sw=new StringWriter();
		jf.invoke(sw);
		num=num+Integer.parseInt(sw.toString());
		out.println(num);
		super.doTag();
	}

}
